<template>
  <div class="crumb">
    <el-breadcrumb separator="/">
      <!-- 面包屑组件 -->
      <template v-for="item in breadcrumbs" :key="item.name">
        <el-breadcrumb-item to="item.path"
          ><a href="/">{{ item.name }}</a></el-breadcrumb-item
        >
      </template>
    </el-breadcrumb>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import useLoginStore from '@/store/login/login'
import { mapPathToBreadcrumbs } from '@/utils/map-menus'

const route = useRoute()
const userMenus = useLoginStore().userMenus
const breadcrumbs = computed(() => {
  return mapPathToBreadcrumbs(route.path, userMenus)
})
</script>

<style lang="less" scoped>
.crumb {
  color: red;
}
</style>
